package com.fulei.device;

import com.bjfl.saleManager.util.LogUtil;
import com.fulei.logic.GetSecurityNumber;

public class XDLDevice
{
  private String deviceType;
  private String comNo;
  private String baudRate;
  
  public XDLDevice(String devType, String com, String brn)
  {
    this.deviceType = devType;
    this.comNo = com;
    this.baudRate = brn;
  }
  
  public String ReadSecurityNumber()
  {
    String return_data = "";
    try
    {
      if ("XDL1".equals(this.deviceType))
      {
        GetSecurityNumber.comNo = this.comNo;
        GetSecurityNumber.baudRate = this.baudRate;
        return_data = GetSecurityNumber.ReadSecurityNumber();
      }
      else if ("XDL2".equals(this.deviceType))
      {
        GetSecurityNumber.comNo = this.comNo;
        GetSecurityNumber.baudRate = this.baudRate;
        return_data = GetSecurityNumber.ReadSportLoterySecurityNumber();
      }
      else if ("XDL3".equals(this.deviceType))
      {
        GetSecurityNumber.comNo = this.comNo;
        GetSecurityNumber.baudRate = this.baudRate;
        return_data = GetSecurityNumber.ReadWelfareLotterySecurityNumber();
      }
    }
    catch (Exception ex)
    {
      LogUtil.writeExceptionLog("扫码接口:" + ex.getMessage());
      return_data = "";
    }
    return return_data;
  }
  
  public void closeSerialPort()
  {
    try
    {
      if ("XDL1".equals(this.deviceType)) {
        GetSecurityNumber.closeSerialPort();
      }
    }
    catch (Exception ex)
    {
      LogUtil.writeExceptionLog("扫码接口:" + ex.getMessage());
    }
  }
}
